
package com.xwli.jdk8new.lambda.test;

import com.xwli.jdk8new.lambda.domain.Person;
import com.xwli.jdk8new.lambda.service.UserService;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

/**
 * @program: springcloud
 * @description: 有参有返回结果的案例
 * @author: xwli
 * @create: 2022-05-05 16:47
 **/
public class LambdaDemo03 {
    public static void main(String[] args) {
        List<Person> personList = new ArrayList<>();
        personList.add(new Person("张三",19,175));
        personList.add(new Person("李四",33,170));
        personList.add(new Person("小美",18,162));
        personList.add(new Person("小明",23,171));
        Collections.sort(personList, new Comparator<Person>() {
            @Override
            public int compare(Person o1, Person o2) {
                return o1.getHeight()-o2.getHeight();
            }
        });
        for (Person person : personList) {
            System.out.println(person);
        }
        System.out.println("------------------------");
        Collections.sort(personList,(Person o1,Person o2)->{
            return o1.getAge() - o2.getAge();
        });
        for (Person person : personList) {
            System.out.println(person);
        }
    }

    public static void goShow(UserService userService){
        userService.show();
    }
}
